package com.capinfo.service.impl;

import com.capinfo.base.BaseEntity;
import com.capinfo.base.BaseMapper;
import com.capinfo.base.impl.BaseServiceImpl;
import com.capinfo.entity.CapServiceType;
import com.capinfo.mapper.CapServiceTypeMapper;
import com.capinfo.service.CapServiceTypeService;
import com.capinfo.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: sunbenjin
 * @date: 2020/3/3
 **/
@Service
public class CapServiceTypeServiceImple extends BaseServiceImpl<CapServiceType, String> implements CapServiceTypeService {

    @Autowired
    CapServiceTypeMapper capServiceTypeMapper;

    @Override
    public List<CapServiceType> selectListByPage(CapServiceType record) {
        return capServiceTypeMapper.selectListByPage(record);
    }

    @Override
    public int insert(CapServiceType capServiceType) {
        capServiceType = super.addValue(capServiceType, false);
        return capServiceTypeMapper.insertSelective(capServiceType);
    }

    @Override
    public int insertSelective(CapServiceType capServiceType) {
        return capServiceTypeMapper.insertSelective(capServiceType);
    }


    @Override
    public CapServiceType selectByPrimaryKey(Object o) {
        return capServiceTypeMapper.selectByPrimaryKey(o);
    }


    @Override
    public BaseMapper<CapServiceType, String> getMappser() {
        return capServiceTypeMapper;
    }


    @Override
    public JsonUtil delById(String id, boolean flag) {
        JsonUtil j=new JsonUtil();

        try {
            CapServiceType sysOffice = selectByPrimaryKey(id);
            if (flag) {
                //逻辑
                sysOffice.setDelFlag(BaseEntity.DEL_FLAG_DELETE);
                updateByPrimaryKeySelective(sysOffice);
            } else {
                //物理
                sysOffice.setDelFlag(BaseEntity.DEL_FLAG_DELETE);
                updateByPrimaryKeySelective(sysOffice);
//                capServiceTypeMapper.delById(id);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        j.setMsg("删除成功");
        return null;
    }
}
